package com.bruce.practice.test;

import org.apache.commons.collections4.MapUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author luotuan
 * @Description
 * @create 2020-08-12 16:59
 **/
public class ListStreamDemo {
    public static void main(String[] args) {
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String,Object> map1 = new HashMap<>();
        map1.put("areaCode","BH");
        map1.put("id","1");
        Map<String,Object> map2 = new HashMap<>();
        map2.put("areaCode","AH");
        map2.put("id","1");
        Map<String,Object> map3 = new HashMap<>();
        map3.put("areaCode","CH");
        map3.put("id","1");
        list.add(map1);
        list.add(map2);
        list.add(map3);
        list = list.stream().filter(map->{
            String value = MapUtils.getString(map,"areaCode");
            return value.equals("H");
        }).collect(Collectors.toList());
        System.out.println(list.size());
    }
}
